package com.wly.datapool.skillpool;

import java.util.ArrayList;
import java.util.Iterator;

import org.apache.mina.core.session.IoSession;

import com.wly.datapool.skillpool.skill.SkillStatic;
import com.wly.define.IDZoneDefine;


public class SkillPool
{
	private ArrayList<SkillStatic> _skillArr;
	private static SkillPool       _instance;
	
	private SkillPool()
	{
		initSkills();
	}
	
	static public SkillPool getInstance()
	{
		if(_instance == null)
		{
			_instance = new SkillPool();
		}
		return _instance;
	}
	
	private void initSkills()
	{
		_skillArr = new ArrayList<SkillStatic>();
	}
	
	public SkillStatic getSkillBySkillId(int skillId)
	{
		return _skillArr.get(skillId-IDZoneDefine.SKILL_START_ID);
	}
	
	public void addSkill(SkillStatic skill)
	{
		_skillArr.add(skill.skillId-IDZoneDefine.SKILL_START_ID, skill);
	}
	
	public void printSkills()
	{
		Iterator it = _skillArr.iterator();
		SkillStatic skill;
		while(it.hasNext())
		{
			skill = (SkillStatic)it.next();
			System.out.println(skill.skillName);
			System.out.println(skill.skillId);
			System.out.println(skill.isAttack);
		}
	}
}
